﻿@model ViVa.ActiveDirectory.ADEntry

    <script type="text/javascript">
    $(function () {
        $("#dialog-NoButtons").dialog({
            autoOpen: false,
            modal: true,
            width: 800,
            open: function (event, ui) { $(".ui-dialog-buttonpane").hide(); }
        });

        $("#opener").click(function () {
            $("#dialog-NoButtons").dialog("open");
            return false;
        });
    });
	</script> 

    <script type="text/javascript">
        $(function () {
            $("#check").button();
        });

</script>

@{
    List<string> sort = new List<string>    {
                                                "Applicaties,dl_appl_",
                                                "Data,dl_data_",
                                                "Mail,mail_",
                                                "Test Applicaties,dl_testappl_"
                                            };
    List<string> sort2 = new List<string>();
}





@using (Html.BeginForm())
{
   <div class="pickme"> 
 
   @foreach (string deel in sort)
   {
       string[] deelArray = deel.Split(',');
       sort2.Add(deelArray[1]);

        <div class="portlet">
        <div class="portlet-header" style="background-color:#E8E8E8">@deelArray[0]</div>
        <div class="portlet-content">
        <table class="pickme">

        @if (Model.MemberOf != null)
        {
        foreach (string group in Model.MemberOf)
        {
            if (group.Contains(deelArray[1]))
            {
                string groupName = group.Remove(0, 3);
                groupName = groupName.Substring(0, groupName.IndexOf(",OU="));
                <tr> <td> @Html.CheckBox(@group.ToString(), false) </td> <td> @groupName </td></tr>
            }
        }
        }
        </table>
        </div>
	</div>

   }




        <div class="portlet">
        <div class="portlet-header" style="background-color:#E8E8E8">Overig</div>
        <div class="portlet-content">
        <table class="pickme">
        @{
            string filter = null;
            foreach(string s in sort2)
            {
            filter = string.Format("&(!group.Contains({0}) &&)",s);
            }
         }
                @if (Model.MemberOf != null)
                {
                    foreach (string group in Model.MemberOf)
                    {

                        if (!sort2.Any(s => group.Contains(s)))
                        {
                            string groupName = group.Remove(0, 3);
                            if (groupName.Contains(",OU=")) { groupName = groupName.Substring(0, groupName.IndexOf(",OU=")); }
                            else { groupName = groupName.Substring(0, groupName.IndexOf(",CN=")); }
                        
                            <tr> <td> @Html.CheckBox(@group.ToString(), false) </td> <td> @Html.Label(@groupName) </td></tr>
                        }
                    }
                }

        </table>
        </div>
        </div>





        <table>
                <tr>
                    <td><br /></td>
                </tr>
                <tr>
                    <td>
                        @Html.HiddenFor(x => x.SamAccountName)
                        @Html.Hidden("action", "DeleteMemberOf")
                        <button type="submit" class="delBTN" >Verwijder aangevinkte groepen </button>
                        <button id="opener" class="searchBTN">Voeg groepen toe</button> 
                    </td>
                </tr>         
        </table>    </div>        

 <div id="dialog-NoButtons" title="Voeg groepen toe"> 
	@Html.Partial("partialViews/_UserAddToGroup")
</div>}